// export var Name = 'Wangzhongyi';

// function Common(){

//     this.test   = function(){
//         console.log('run common test');
//     }
// }

// export var common   = new Common();

export default {

    //批量获取字符串
    getBatchString : function(string, count){
        var s   = '';
        for(let i = 0; i < count; i++){
            s += string;
        }

        return s;
    },

    //克隆对象
    clone : function(object){
        return JSON.parse(JSON.stringify(object));
    },

    //路由
    route : function(anchor) {
        if(anchor){
            window.open('#' + anchor, '_self');
            return true;
        }else{
            return '';
        }
    },

    //去页面
    toUrl : function(url){
        window.open('/#' + url, '_self')
    },

    //字符串裁剪
    stringCut : function(string, length, postfix){
        var postfix = postfix || '...'

        if(string.length > length){
            return string.substr(0, length) + postfix
        }else{
            return string
        }
    },

    //url参数获取
    getUrlParam : function(par){
        //获取当前URL
        var local_url = document.location.href; 
        //获取要取得的get参数位置
        var get = local_url.indexOf(par +"=");
        if(get == -1){
            return false;   
        }   
        //截取字符串
        var get_par = local_url.slice(par.length + get + 1);    
        //判断截取后的字符串是否还有其他get参数
        var nextPar = get_par.indexOf("&") > get_par.indexOf("#") ? 
            get_par.indexOf("&") :get_par.indexOf("#")
        if(nextPar != -1){
            get_par = get_par.slice(0, nextPar);
        }
        return get_par;
    }
}